Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class PHONGBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As PHONGDto)
 Dim Dao As New PHONGDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDPHONG As System.Int32)
 Dim Dao As New PHONGDao(ketnoi)
 Dao.xoa(IDPHONG)
 End Sub
 Public Sub sua(ByVal Dto As PHONGDto)
 Dim Dao As New PHONGDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New PHONGDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoPHONG As PHONGdto = LayBangDTo(i, Dao) 
 aList.Add(dtoPHONG)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaTENPHONG( ByVal TENPHONG as System.String, ByVal IDPHONG As System.Int32 )
 Dim dao As New PHONGDao(ketnoi)
 dao.suaTENPHONG(TENPHONG,IDPHONG)
 End Sub 
 Public Sub suaSOBAN_GHE( ByVal SOBAN_GHE as System.Int32, ByVal IDPHONG As System.Int32 )
 Dim dao As New PHONGDao(ketnoi)
 dao.suaSOBAN_GHE(SOBAN_GHE,IDPHONG)
 End Sub 
 Public Sub suaNHANH( ByVal NHANH as System.Int32, ByVal IDPHONG As System.Int32 )
 Dim dao As New PHONGDao(ketnoi)
 dao.suaNHANH(NHANH,IDPHONG)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDPHONG As System.Int32 )
 Dim dao As New PHONGDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDPHONG)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.String, ByVal IDPHONG As System.Int32 )
 Dim dao As New PHONGDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDPHONG)
 End Sub 
 Public Function LayBangTable( ByVal IDPHONG As System.Int32) As DataTable
 Dim Dao As New PHONGDao(IDPHONG,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDPHONG As System.Int32) As IList
 Dim Dao As New PHONGDao(IDPHONG,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoPHONG As PHONGdto = LayBangDTo(i, Dao) 
 aList.Add(dtoPHONG)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDPHONG (ByVal IDPHONG As System.Int32) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoIDPHONG(IDPHONG)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDPHONG (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoIDPHONG(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDPHONG (ByVal IDPHONG As System.Int32) 
 Dim Dao As New PHONGDao(ketnoi)
 Dao.XOABangTheoIDPHONG(IDPHONG)
 End sub
 Public Function LayBangTableTheoTENPHONG (ByVal TENPHONG As System.String) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoTENPHONG(TENPHONG)
 Return Dao
 End Function
 Public Function LayBangTableTheoTENPHONG_like (ByVal TENPHONG As System.String ) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoTENPHONG_like (TENPHONG)
 Return Dao
 End Function
 Public Function LayBangTableTheoTENPHONG (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoTENPHONG(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTENPHONG (ByVal TENPHONG As System.String) 
 Dim Dao As New PHONGDao(ketnoi)
 Dao.XOABangTheoTENPHONG(TENPHONG)
 End sub
 Public Function LayBangTableTheoSOBAN_GHE (ByVal SOBAN_GHE As System.Int32) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoSOBAN_GHE(SOBAN_GHE)
 Return Dao
 End Function
 Public Function LayBangTableTheoSOBAN_GHE (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoSOBAN_GHE(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoSOBAN_GHE (ByVal SOBAN_GHE As System.Int32) 
 Dim Dao As New PHONGDao(ketnoi)
 Dao.XOABangTheoSOBAN_GHE(SOBAN_GHE)
 End sub
 Public Function LayBangTableTheoNHANH (ByVal NHANH As System.Int32) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoNHANH(NHANH)
 Return Dao
 End Function
 Public Function LayBangTableTheoNHANH (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoNHANH(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoNHANH (ByVal NHANH As System.Int32) 
 Dim Dao As New PHONGDao(ketnoi)
 Dao.XOABangTheoNHANH(NHANH)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New PHONGDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.String) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU_like (ByVal GHICHU As System.String ) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoGHICHU_like (GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.String) 
 Dim Dao As New PHONGDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDPHONG As System.Int32) As PHONGdto
 Dim Dao As New PHONGDao(IDPHONG, ketnoi)
 Dim dto As New PHONGdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDPHONG")) = False Then
 Dto.IDPHONG = Dao.Rows(0)("IDPHONG")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONG.IDPHONG")) = False Then
 Dto.IDPHONG = Dao.Rows(0)("PHONG.IDPHONG")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TENPHONG")) = False Then
 Dto.TENPHONG = Dao.Rows(0)("TENPHONG")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONG.TENPHONG")) = False Then
 Dto.TENPHONG = Dao.Rows(0)("PHONG.TENPHONG")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("SOBAN_GHE")) = False Then
 Dto.SOBAN_GHE = Dao.Rows(0)("SOBAN_GHE")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONG.SOBAN_GHE")) = False Then
 Dto.SOBAN_GHE = Dao.Rows(0)("PHONG.SOBAN_GHE")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("NHANH")) = False Then
 Dto.NHANH = Dao.Rows(0)("NHANH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONG.NHANH")) = False Then
 Dto.NHANH = Dao.Rows(0)("PHONG.NHANH")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONG.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("PHONG.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONG.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("PHONG.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As PHONGdto
 Dim dto As New PHONGdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDPHONG")) = False Then
 Dto.IDPHONG = Dao.Rows(i)("IDPHONG")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONG.IDPHONG")) = False Then
 Dto.IDPHONG = Dao.Rows(i)("PHONG.IDPHONG")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TENPHONG")) = False Then
 Dto.TENPHONG = Dao.Rows(i)("TENPHONG")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONG.TENPHONG")) = False Then
 Dto.TENPHONG = Dao.Rows(i)("PHONG.TENPHONG")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("SOBAN_GHE")) = False Then
 Dto.SOBAN_GHE = Dao.Rows(i)("SOBAN_GHE")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONG.SOBAN_GHE")) = False Then
 Dto.SOBAN_GHE = Dao.Rows(i)("PHONG.SOBAN_GHE")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("NHANH")) = False Then
 Dto.NHANH = Dao.Rows(i)("NHANH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONG.NHANH")) = False Then
 Dto.NHANH = Dao.Rows(i)("PHONG.NHANH")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONG.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("PHONG.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONG.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("PHONG.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As PHONGdto
 Dim dto As New PHONGdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New PHONGDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New PHONGDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

